/*
 * Created on Dec 1, 2004
 */
package com.zabada.sample;

import java.util.Date;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author rlambert
 */
public class ShowSamples
{
  public static void main(String[] args) throws InterruptedException
  {
    ApplicationContext context = new ClassPathXmlApplicationContext("/sample-config.xml");
    
    SampleInterface sampleRaw = (SampleInterface)context.getBean("sampleInterfaceImpl");
    SampleInterface sampleWithInterceptor = (SampleInterface)context.getBean("sampleInterfaceWithInterceptor");

    System.out.println("\nLOOPING OVER sampleRaw 10 TIMES (ALL VALUES SHOULD BE DIFFERENT)");
    for(int i = 0; i<10; i++)
    {
      Date rawDate = sampleRaw.getCurrentDate();
      Thread.sleep(1000);
      System.out.println("***************#"+i + ": " + rawDate + " MILLIS: " + rawDate.getTime());
    }

    System.out.println("\nLOOPING OVER sampleWithInterceptor 10 TIMES.");
    System.out.println("ALL VALUES SHOULD BE THE SAME, BECAUSE AFTER 1st CALL, VALUE SHOULD BE CACHED");
    for(int i = 0; i<10; i++)
    {
      Date interceptedDate = sampleWithInterceptor.getCurrentDate();
      Thread.sleep(1000);
      System.out.println("***************#"+i + ": " + interceptedDate + " MILLIS: " + interceptedDate.getTime());
    }
  }
}
